package com.heima.web;

import com.heima.UserService.impl.BrandServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "DeleteServlet", value = "/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        BrandServiceImpl service = new BrandServiceImpl();
        Boolean b = service.deleteBrand(Integer.parseInt(id));
        if (b){
            response.sendRedirect("SelectAllServlet");
            System.out.println("删除成功");
        }else {
            response.sendRedirect("/err.jsp");
            System.out.println("删除成功");
        }
    }
}
